package constants

import (
	"strings"
)

// common response code
const (
	CodeHTTPStart              = 100
	CodeHTTPEnd                = 600
	CodeInvalid                = -99999 // 无效错误码
	CodeOk                     = 0      // 成功
	CodeSystemException        = -1     // 系统异常
	CodeNotFound               = 404
	CodeInputParamInvalid      = 10000
	CodeInputJSONInvalid       = 10001
	CodeDataMissing            = 10002
	CodeReadDbFailed           = 10003
	CodeWriteDbFailed          = 10004
	CodeSendEmailFailed        = 10005
	CodeInvalidFileData        = 10006
	CodeQueryFailed            = 10007
	CodeFileUploadFailed       = 10008
	CodeTransferFileFailed     = 10009
	CodeInvalidSession         = 10010
	CodeNotImplement           = 10011
	CodeInvalidKey             = 10012
	CodeShortenFailed          = 10013
	CodeSaveLogToEsFailed      = 10014
	CodeSaveLogToFileFailed    = 10015
	CodeReadRedisFailed        = 10016
	CodeWriteRedisFailed       = 10017
	CodeBlackListLimit         = 10018
	CodeGetAccountFailed       = 100018
	CodeCheckEventFailed       = 100019
	CodeCheckNumFailed         = 100020
	CodeGetDataFailed          = 100021
	CodeGetDataTimeout         = 100022
	CodeLoginLimit             = 100023
	CodeHeadErr                = 100024
	CodeAntsPoolNil            = 100025
	CodeBuildKvsURLFailed      = 100026
	CodeBlackListLoginLimit    = 100027
	CodeMaxLoginLimit          = 100028
	CodeEncryptFailed          = 100029
	CodeDecryptFailed          = 100030
	CodeeWriteDynamoDbFailed   = 100031
	CodeNeedCaptcha            = 100032
	CodeCaptchaError           = 100033
	CodeMaxRegisterError       = 100034
	CodeMaxForgetPasswordError = 100035
	CodeDynamodbClientFailed   = 100036
	CodeWriteDynamodbFailed    = 100037
	CodeReaddDynamodbFailed    = 100038
	CodeReachMaxUploadNum      = 100039
	CodeSolarChargingNotSupport = 100040

	CodeSelfCheckFailed         = 100050
)

// equipment response code
const (
	CodeStationNotExist        = 20000
	CodeStationExist           = 20001
	CodeStationBinded          = 20002
	CodeStationNotBinded       = 20003
	CodeStationNotAdmin        = 20004
	CodeDeviceBinded           = 20005
	CodeDeviceBindedToAnother  = 20006
	CodeDeviceNotBinded        = 20007
	CodeDeviceNotExist         = 20008
	CodeDeviceExist            = 20009
	CodeStationNotReset        = 20010
	CodeDeviceNotAdmin         = 20011
	CodeStationAllocated       = 20012
	CodeRunOutOfDid            = 20013
	CodeDidExist               = 20014
	CodeDeviceAllocated        = 20015
	CodeRunOutOfRtsp           = 20016
	CodeRtspExist              = 20017
	CodeDidServerExist         = 20018
	CodeDidServerNotExist      = 20019
	CodeStationBindedToAnother = 20020
	CodeDeviceNotShare         = 20021
	CodeStartStreamFailed      = 20022
	CodeStopStreamFailed       = 20023
	CodeDeviceDelParamFailed   = 20024
	CodeRunOutOfHomekitToken   = 20025
	CodeSetupCodeNotExist      = 20026
	CodeSunCalcFailed          = 20027
	CodeStationNotMember       = 20028
	CodeSendEventEmailFailed   = 20029
	CodeDeviceNotIntegrated    = 20030
	CodeAppSummaryEmpty        = 20031
	CodeCheckCodeFailed        = 20032
	CodeCheckValidityFailed    = 20033
	CodeDidNotExist            = 20034
)

// monitor response code
const (
	CodeEventNotExist        = 21000
	CodeEventNotAuth         = 21001
	CodeEventFavorited       = 21002
	CodeEventNotFavorited    = 21003
	CodeEventPartialNotExist = 21004
)

// family response code
const (
	CodeStationMemberExist        = 22000
	CodeStationMemberNotExist     = 22001
	CodeStationSuperAdmin         = 22002
	CodeStationDeviceNotExist     = 22003
	CodeStationMemberInvited      = 22004
	CodeStationMemberNotInvited   = 22005
	CodeStationNotSuperAdmin      = 22006
	CodeUnauthorizeSelf           = 22007
	CodeStationMemberNotRegister  = 22008
	CodeStationInviteSelfDisallow = 22009
	CodeStationEntryOnlyExist     = 22010
	CodeStationEntryOnlyNotExist  = 22011
)

// cloud response code
const (
	CodeStorageNotOpen       = 24000
	CodeUserNotrial          = 24001
	CodeStorageOpened        = 24002
	CodeStorageExpired       = 24003
	CodePackageNotExist      = 24004
	CodeTrialedAndExpired    = 24005
	CodeTrialPackageNotExist = 24006
	CodePackageIsTrial       = 24007
	CodeStorageNotSupport    = 24008
)

// order response code
const (
	CodeOrderNotExistOrExpired   = 25000
	CodeOrderNotCreated          = 25001
	CodeOrderNotPayed            = 25002
	CodeOrderChargeFailed        = 25003
	CodeOrderRefundFailed        = 25004
	CodeOrderChargeSuccDbFailed  = 25005
	CodeOrderRefundSuccDbFailed  = 25006
	CodeInvalidSubscription      = 25007
	CodeCancelSubscriptionFailed = 25008
	CodeDeviceNotSubscribed      = 25009
	CodeCreatePlanFailed         = 25010
	CodeCreateSubscriptionFailed = 25011
	CodeUpdateSubscriptionFailed = 25012
	CodeDeviceAlreadySubscribed  = 25013
	CodeCreateCustomerFailed     = 25014
	CodeConflictSubscription     = 25015

	CodeStripeCardDeclined    = 25016
	CodeStripeExpiredCard     = 25017
	CodeStripeIncorrectNum    = 25018
	CodeStripeInvalidCvc      = 25019
	CodeStripeInvalidExpM     = 25020
	CodeStripeInvalidExpY     = 25021
	CodeStripeInvalidNum      = 25022
	CodeStripeIncorrectCvc    = 25023
	CodeStripeIncorrectZip    = 25024
	CodeStripeMissing         = 25025
	CodeStripeProcessingErr   = 25026
	CodeStripeRateLimit       = 25027
	CodeStripeResourceMissing = 25028

	CodeSubscriptionPracticeModeEnabled  = 25040 // 练习模式已启用
	CodeSubscriptionPracticeModeDisabled = 25041 // 练习模式未启用
	CodeSubscribingSubscription          = 25042 // 还在订阅中
	CodeInvalidMonitoringSubscription    = 25043 // 无效报警订阅

	CodeAllocateRedeemCodeErr            = 25050 //分配redeem code 失败
	CodeAuthInterfaceFail                = 25051 //认证接口失败
	CodeRedeemReqParamFail               = 25052 //请求参数不对
	CodeRedeemGenerateFail               = 25053 //兑换码产生失败
	CodeRedeemPkgNotExist                = 25054 //套餐不存在
	CodeRedeemWriteDbFail                = 25055 //写兑换码失败
	CodeRedeemOpRedisFail                = 25056 //操作redis失败
	CodeRedeemCaptchaFreshTooMuch        = 25057 //刷新验证码次数过多
	CodeRedeemCaptchaGenerateFail        = 25058 //生成图形验证码失败
	CodeRedeemCodeOpTooMuch              = 25059 //兑换码兑换次数过多,需要休息一下
	CodeRedeemCaptchaOpTooMuch           = 25060 //兑换输入验证码次数过多
	CodeRedeemCaptchaParamInvalid        = 25061 //输入图像验证码不全，部分字段为空
	CodeRedeemLostCaptcha                = 25062 //兑换时没有输入有效的验证码
	CodeRedeemRedeemed                  = 25063 //兑换码已经兑换
	CodeRedeemRedeemFail                 = 25064 //兑换失败
	CodeRedeemNeedCaptcha                = 25065 //兑换失败，下次兑换时需先请求验证码再兑换
	CodeRedeemFromMemFail                = 25066 //从存储查询兑换码失败
	CodeRedeemNotOnRedeeming             = 25067 //兑换码不在兑换中状态
	CodeRedeemInparamInvalid             = 25068 //无效入参
	CodeRedeemNotOnCreated               = 25069 //兑换码不在创建状态中
	CodeRedeemSubscriptionNotExist       = 25070 //订阅不存在
	CodeRedeemCodeExpired                = 25071 //兑换码已过期
	CodeRedeemOpUserDiff                 = 25072 //非法用户兑换
	CodeRedeemCodeNotExist               = 25073 //兑换码不存在

)

// passport response code
const (
	CodeRegisterFailed                         = 26000
	CodeValidateEmailFailed                    = 26001
	CodeActivateFailed                         = 26002
	CodeForgetPasswordFailed                   = 26003
	CodeChangePasswordFailed                   = 26004
	CodeThirdPartyLoginFailed                  = 26005
	CodeLoginFailed                            = 26006
	CodeAutoLoginFailed                        = 26007
	CodeGetProfileFailed                       = 26008
	CodeSubscribeEmailsFailed                  = 26009
	CodeUpdateProfileFailed                    = 26010
	CodeEditAvatarFailed                       = 26011
	CodeUserNotExist                           = 26012
	CodeResetPasswordFailed                    = 26013
	CodeResendActiveEmailFailed                = 26014
	CodeAccountNotActivated                    = 26015
	CodeDestroyUserFailed                      = 26016
	CodeSaveAccountToRedisFailed               = 26017
	CodeValidateTokenFailed                    = 26018
	CodeGetCountriesFailed                     = 26019
	CodeGetStatesFailed                        = 26020
	CodeEmailIsBlank                           = 26021
	CodePasswordIsBlank                        = 26022
	CodeAccountHasBeenDisabled                 = 26023
	CodeAccountHasBeenActivated                = 26024
	CodeEmailIsNotExisted                      = 26025
	CodeTokenExpired                           = 26026
	CodePasswordIsIncorrect                    = 26027
	CodeRegistedWithSocial                     = 26028
	CodePasswordNotStrong                      = 26029
	CodeEmailFormatWrong                       = 26030
	CodePasswordUpdatedSuccess                 = 26031
	CodeCaptchaInvalid                         = 26032
	CodeEmailHasRegistered                     = 26033
	CodeActiveFailed                           = 26034
	CodeTokenInvalid                           = 26035
	CodePasswordResetTokenInvalid              = 26036
	CodeInvalidOldPassword                     = 26037
	CodeEmailIsExistedSubscribe                = 26038
	CodeInvalidApplicationNameOrApplicationKey = 26039
	CodeInvalidSign                            = 26040
	CodeMultiDeviceTokenInvalid                = 26041
	CodeSendMemoEmailFailed                    = 26042
	CodeLogoutFailed                           = 26043
	CodeLogoutFailToClearToken                 = 26044
	CodeBindLoginIdFailed                      = 26045
	CodeUnBindLoginIdFailed                    = 26046
	CodeLoginIdFailed                          = 26047
	CodeResetPasswordNoticeSignFailed          = 26048
	CodeModelTypeLoginLimit                    = 26049
	CodeVerifyCodeError                        = 26050 //校验码错误
	CodeVerifyCodeOverdue                      = 26051 //校验码过期
	CodeNeedVerifyCode                         = 26052 //需要校验码
	CodeMaxSendError                           = 26053 //发送短信达到上限
	CodePhoneNotMatchVerifyCode                = 26054 //手机号码和校验码不匹配
	CodePasswordVerifyError                    = 26055 //验证密码失败
	CodePushMessageNoMore                      = 26056 //推送验证消息，除了当前请求的设备外没有多余的信任设备
	CodePasswordIllegal                        = 26057 //密码长度非法等
	CodeNotSupportSendSms                      = 26058 //该国家不支持发送短信
	CodeGetSubscriptionsFailed                 = 26059
	CodeSetSubscriptionsFailed                 = 26060
	CodeUserNameLengthLimit                    = 26061 //用户昵称长度限制
	CodeUserNameCharacterLimit                 = 26062 //用户昵称字符限制
	CodeUserPinNotExist                        = 26063 //pin码不存在
	CodeUserPinError                           = 26064 //pin码错误
	CodeVerifyCodeErrorLimit                   = 26065 //验证码错误达到上限
	CodeDataNotTheSame                         = 26066 //数据对比不一致，比如：用户中心返回数据和我们这边数据不一致
)

// notification response code
const (
	CodeStationNotConnected = 27000
)

// admin response code
const (
	CodeAdminUserNotExist     = 28000
	CodeSetSessionFailed      = 28001
	CodeDeleteSessionFailed   = 28002
	CodeNotSuperAdmin         = 28003
	CodeAdminUserExist        = 28004
	CodeModifyPasswordFailed  = 28005
	CodeDeleteUsersFailed     = 28006
	CodeUndeleteUsersFailed   = 28007
	CodeInvalidUserOrPassword = 28008
	CodeUpdateUserFailed      = 28009
	CodeNotOpsAdmin           = 28010
	CodePopupBoxExist         = 28011
	CodePopupControlExist     = 28012
	CodeAdminGroupExist       = 28013
	CodeAdminPageExist        = 28014
	CodeStoreProdExist        = 28015
	CodeSendCmdFailed         = 28016
)

// aiassis response code
const (
	CodeAiAssisGroupNotExist       = 29000
	CodeAiAssisGroupExist          = 29001
	CodeAiAssisDeleteGroupsFailed  = 29002
	CodeAiAssisUserNotExist        = 29003
	CodeAiAssisUserExist           = 29004
	CodeAiAssisDeleteUsersFailed   = 29005
	CodeAiAssisMonitorFaceNotExist = 29006
	CodeAiAssisDeleteFaceFailed    = 29007
	CodeAiAssisGroupHasUsers       = 29008
	CodeAiAssisFaceNotExist        = 29009
)

// feedback response code
const (
	CodeGeneralCreateFailed = 30000
)

// sector response code
const (
	CodeSectorAlreadyExist = 31000
	CodeSectorNotExist     = 31001
	CodeSectorHasDevices   = 31002
	CodeSectorDefaultExist = 31003
)

// ota response code
const (
	CodeOtaDeviceTypeNotExist = 32000
	CodeOtaGrayBatchNotExist  = 32001
)

// overall response code
const (
	CodeOverallParentNotExist = 33000
)

// cipher response code
const (
	CodeCipherGenerateFailed = 34000
)

// review response code
const (
	CodeReviewDayLimitReach = 35000
)

// emergency response code
const (
	CodeEmergencyDeviceUsed              = 36000
	CodeEmergencyInvalidConf             = 36001
	CodeEmergencyAlarmActivated          = 36002
	CodeEmergencyCreateAlarmFailed       = 36003
	CodeEmergencyAlarmNotActive          = 36004
	CodeEmergencyAlarmNotExist           = 36005
	CodeEmergencyCancelAlarmFailed       = 36006
	CodeEmergencyInvalidStation          = 36007
	CodeEmergencyInvalidDevice           = 36008
	CodeEmergencyGetAlarmStatusFailed    = 36009
	CodeEmergencyContactExist            = 36010
	CodeEmergencyContactNotExist         = 36011
	CodeEmergencyAutoFlagIsOff           = 36012
	CodeEmergencyIgnoreDelayAlarm        = 36013
	CodeEmergencyInLeavingDelay          = 36014
	CodeEmergencyInDelayQueue            = 36015
	CodeEmergencySendBagFailed           = 36016
	CodeEmergencyAlertNotExist           = 36017
	CodeEmergencyCreateEventFailed       = 36018
	CodeEmergencyPracticeModeEnabled     = 36019 // 练习模式已启用
	CodeEmergencyPracticeModeDisabled    = 36020 // 练习模式未启用
	CodeEmergencyCreateCertificateFailed = 36021
	CodeEmergencyOldPingcodeNotMatch     = 36022
	CodeEmergencyCheckPincodeInvalid     = 36023
)

// tcp response code
const (
	CodeInvalidStation     = 40000
	CodeSaveStationFailed  = 40001
	CodeConnectionNotExist = 40002
	CodeTransferFailed     = 40003
)

// smart home code
const (
	CodeSmartUnauth       = 41000
	CodeSmartGetUrlFailed = 41001
)

// geofence code
const (
	CodeGeofenceNoGeoDataFound          = 42000
	CodeGeofenceNoUserDeviceData        = 42001
	CodeGeofenceAddNoUserInfo           = 42002
	CodeGeofenceNoValidUserGeoEnabled   = 42003
	CodeGeofenceUpdateNewDataFailed     = 42004
	CodeGeofenceUpdateOldDataFailed     = 42005
	CodeGeofenceNoInvitation            = 42006
	CodeGeofenceInvalidInviteParam      = 42007
	CodeGeofenceUpdateNoUserInfo        = 42008
	CodeGeofenceUpdateNoEnableUserInfo  = 42009
	CodeGeofenceMsgUpdateUserInfoFailed = 42010
	CodeGeofenceDeleteGeoDataFail       = 42011
	CodeGeofenceMsgInvite               = 42056
	CodeGeofenceMsgEnableLocation       = 42057
)

// template code
const (
	TemplateFieldRequired              = 50000
	TemplateFailedToRequest            = 50001
	TemplatePaymentFailed              = 50100
	TemplatePaymentSucceed             = 50101
	TemplateSubscriptionSucceed        = 50102
	TemplateSubscriptionDeleted        = 50103
	TemplateSubscriptionExpiring       = 50104
	TemplateInviteIgnored              = 50105
	TemplateInviteCleared              = 50106
	TemplateInviteRemoved              = 50107
	TemplateInviteDeleted              = 50108
	TemplateUpgradeAutoSucceed         = 50109
	TemplateUpgradeManualSucceed       = 50110
	TemplateUpgradeManualFailed        = 50111
	TemplateDeviceUpgradeAutoSucceed   = 50112
	TemplateDeviceUpgradeManualSucceed = 50113
	TemplateDeviceUpgradeManualFailed  = 50114
	TemplateAbnormalTemperatureAlarm   = 50115
	TemplateSubscriptionTrialExpiring  = 50116

	// 空出预留值
	TemplateMonitoringSubscriptionSucceed       = 50500
	TemplateMonitoringSubscriptionDeleted       = 50501
	TemplateMonitoringSubscriptionExpiring      = 50502
	TemplateMonitoringSubscriptionTrialExpiring = 50503
)

const (
	TemplateEventThirdpartyCancelNotify = 51000
	TemplateEventKeypadCreateAlarm      = 51001
	TemplateEventKeypadCancelAlarm      = 51002
	TemplateEventDeviceCreateAlarm      = 51003
	TemplateEventPeopleCreateAlarm      = 51004
	TemplateEventPeopleCancelAlarm      = 51005
	TemplateEventAlarmStatusChanged     = 51006
	TemplateEventThirdpartyPsapNotify   = 51007
)

const (
	HelpDbField             = 60000
	HelpDbInsertProductErr  = 60001
	HelpDbGetProductErr     = 60002
	HelpDbUpdateProductErr  = 60003
	HelpDbInsertQuestionErr = 60004
)

const (
	CodeAppPushNoCountFound               = 70000
	CodeAppPushNoTokenFound               = 70001
	CodeAppPushInsertTokenFailed          = 70002
	CodeAppPushUpdateTokenFailed          = 70003
	CodeAppPushUpdateTokensFailed         = 70004
	CodeAppPushReadTokenError             = 70005
	CodeAppPushInsertDuplicateTokenFailed = 70006
	CodeAppPushUpdateDuplicateTokenFailed = 70007
	CodeAppPushOpenudidNotMatch           = 70008
)

const (
	DbField           = 36000
	AddAccordErr      = 36001
	EditAccordErr     = 36002
	AllAccordErr      = 36003
	GetUserRangeIDErr = 36004
)

const (
	TemplateEventTypeUnBind     = 80000
	TemplateEventTypeAtDoorbell = 80001
)

//smart lock专用状态状态码
const (
	NOT_SMART_LOCK_SN                    = 80000 //不是smark lock的sn
	SMART_LOCK_MAC_ERROR                 = 80001 //smark lock的mac地址错误
	SMART_LOCK_ILLEGAL_USER_ERROR        = 80002 //用户跟门锁没有关系
	SMART_LOCK_CREATE_CERTIFICATE_ERROR  = 80003 //创建三级证书失败，在校验证书是否生成成功返回
	SMART_LOCK_USER_NOT_LINK_DEVICE      = 80004 //用户没有跟次设备相关联
	SMART_LOCK_USER_NO_PERMISSIONS       = 80005 //用户没有权限
	SMART_LOCK_NOT_DELETE_THIS_TYPE_USER = 80006 //不能删除次类型用户
	SMART_LOCK_COMMAND_ERROR             = 80007 //指令错误
	SMART_LOCK_SIGN_ERROR                = 80008 //签名校验错误
	SMART_LOCK_REPEATED_REQUEST          = 80009 //重复请求或者过期请求
	SMART_LOCK_CRT_PRXIF                 = "-----BEGIN CERTIFICATE-----"
	SMART_LOCK_CRT_END                   = "-----END CERTIFICATE-----"
	SMART_LOCK_OFFLINE                   = 80010 //设备offline
	SMART_LOCK_AES_KEY_ERROR             = 80011
	SMART_LOCK_DEVICE_ALREADY_RELATE     = 80012 //门铃或者摄像头设备已被其他锁绑定
	SMART_LOCK_SHORT_ID_EXIST            = 80013 //short_user_id 已经存在
)

const (
	Code2faMessage = 90001
)

// shopping
const (
	CodeShoppingNoNewFeatureFound   = 100000 //为找到新Feature版本
	CodeShoppingNoActivityAvailable = 100001
	CodeShoppingNoNotifyFound       = 100002
)

//limit
const (
	CodeIpRateLimit    = 110000
	CodeUserRateLimit  = 110001
	CustomRateLimit    = 110002
	OpendUdidRateLimit = 110003
)

//smartDrop
const (
	GenUUIDError        = 120001
	GenShortUserIDError = 120001
)

const (
	ClientSecretError = 130000
	RefreshTokenError = 130001
)

// Care
const (
	CodeCareBBMQrVerityFailed = 130000 //
)

var SMART_LOCK_MESSAGE_MAP = map[int]string{
	NOT_SMART_LOCK_SN:                    "",
	SMART_LOCK_MAC_ERROR:                 "",
	SMART_LOCK_ILLEGAL_USER_ERROR:        "",
	SMART_LOCK_CREATE_CERTIFICATE_ERROR:  "",
	SMART_LOCK_USER_NOT_LINK_DEVICE:      "",
	SMART_LOCK_USER_NO_PERMISSIONS:       "",
	SMART_LOCK_NOT_DELETE_THIS_TYPE_USER: "",
	SMART_LOCK_OFFLINE:                   "",
	SMART_LOCK_DEVICE_ALREADY_RELATE:     "relate device already related",
	SMART_LOCK_SHORT_ID_EXIST:            "short_user_id already exist",
}

const (
	LinksExpire = 7 * 86400 //s3下载链接的过期时间，一周
)

// CodeText code to text transformer
func CodeText(code int) string {
	return codeText[code]
}

func GetDefaultErrorMsg(code int, lang string) (ret string) {
	if code >= CodeHTTPStart && code <= CodeHTTPEnd {
		// 若是http错误码且直接跳出
		return
	}
	if code > CodeInvalid {
		lang = strings.ToLower(lang)
		codeMap := codeText
		switch lang {
		case LangZh:
			codeMap = codeTextCn
		case LangEs:
			codeMap = codeTextEs
		case LangFr:
			codeMap = codeTextFr
		case LangDe:
			codeMap = codeTextDe
		case LangIt:
			codeMap = codeTextIt
		case LangNl:
			codeMap = codeTextNl
		case LangAr:
			codeMap = codeTextAr
		case LangJa:
			codeMap = codeTextJp
		case LangKo:
			codeMap = codeTextKo
		case LangVi:
			codeMap = codeTextVi
		default:
		}
		ret = codeMap[CodeOk]
		if code != CodeOk {
			ret = codeMap[TemplateFailedToRequest]
		}
	}
	return
}

// GetTextByCode code to text transformer
func GetTextByCode(code int, lang string) (ret string) {
	if code >= CodeHTTPStart && code <= CodeHTTPEnd {
		// 若是http错误码且直接跳出
		return
	}
	if code > CodeInvalid {
		lang = strings.ToLower(lang)
		codeMap := codeText
		switch lang {
		case LangZh:
			codeMap = codeTextCn
		case LangEs:
			codeMap = codeTextEs
		case LangFr:
			codeMap = codeTextFr
		case LangDe:
			codeMap = codeTextDe
		case LangIt:
			codeMap = codeTextIt
		case LangNl:
			codeMap = codeTextNl
		case LangAr:
			codeMap = codeTextAr
		case LangJa:
			codeMap = codeTextJp
		case LangKo:
			codeMap = codeTextKo
		case LangVi:
			codeMap = codeTextVi
		default:
		}
		var ok bool
		// 若存在对应语言文本则返回
		if ret, ok = codeMap[code]; ok {
			return
		}
		// 若没有对应语言，存在英语文本则返回
		if ret, ok = codeText[code]; ok {
			return
		}
		// 最后才使用英语请求失败的文本
		ret = codeText[TemplateFailedToRequest]
	}
	return
}

// GetTextByCodeDefault code to text transformer
func GetTextByCodeDefault(code int) (ret string) {
	return GetTextByCode(code, LangEn)
}
